package gis.adapter;

import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.xkh.xkh.MyApplication;
import com.xkh.xkh.R;

import java.util.ArrayList;
import java.util.List;

import utils.TimeUtil;

/**
 * Created by Administrator on 2016/12/9.
 */
public class TimeAdapter extends BaseAdapter{

    List<Long> viewTimes = new ArrayList<Long>();

    public List<Long> getViewTimes() {
        return viewTimes;
    }

    public void setViewTimes(List<Long> viewTimes) {
        this.viewTimes = viewTimes;
    }

    public TimeAdapter(List<Long> viewTimes) {
        this.viewTimes = viewTimes;
    }

    @Override
    public int getCount() {
        return viewTimes.size();
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(int i, View convertView, ViewGroup viewGroup) {
        ViewHolder viewHolder = null;
        if (convertView == null) {
            viewHolder = new ViewHolder();
            convertView = View.inflate(MyApplication.share(), R.layout.item_viewtime, null);
            viewHolder.tv_time = (TextView) convertView.findViewById(R.id.id_tv_time);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        Long timestamp = viewTimes.get(i);
        viewHolder.tv_time.setText(TimeUtil.timestamp2Format(timestamp));
        return convertView;
    }

    class ViewHolder {
        public TextView tv_time;
    }
}
